import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [
    //登录
    {
      path: '/',
      name: 'index',
      component: () => import('@/views/login/index'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/login'),
    },
    {
      path: '/reset',
      name: 'reset',
      component: () => import('@/views/login/reset'),
      meta: { 
        title: '' 
      }
    },
    {
      path: '/roles',
      name: 'roles',
      component: () => import('@/views/login/roles'),
    },

    // 书架
    {
      path: '/bookshelf',
      name: 'bookshelf',
      component: () => import('@/views/bookshelf/index'),
    },
    {
      path: '/bookDetail',
      name: 'bookDetail',
      component: () => import('@/views/bookshelf/detail'),
    },
    { // 历史任务
      path: '/history',
      name: 'history',
      component: () => import('@/views/bookshelf/history'),
    },
    {
      path: '/review',
      name: 'review',
      component: () => import('@/views/bookshelf/review'),
    },
    {
      path: '/readview',
      name: 'readview',
      component: () => import('@/views/bookshelf/readview'),
    },
    { // 创建任务
      path: '/createTask',
      name: 'createTask',
      component: () => import('@/views/bookshelf/task'),
    },
    { // 在线试读
      path: '/readOnLine',
      name: 'readOnLine',
      component: () => import('@/views/bookshelf/read'),
    },
    // 图书馆
    {
      path: '/library',
      name: 'library',
      component: () => import('@/views/library/index'),
    },
    {
      path: '/libList',
      name: 'libList',
      component: () => import('@/views/library/list'),
    },
    {//搜索
      path: '/search',
      name: 'search',
      component: () => import('@/views/library/search'),
    },

    //任务中心
    {
      path: '/taskList',
      name: 'taskList',
      component: () => import('@/views/student/task-list'),
    },

    // 个人中心
    {
      path: '/user',
      name: 'userCenter',
      component: () => import('@/views/user'),
    },
    { //读后感列表页
      path: '/reviewList',
      name: 'reviewList',
      component: () => import('@/views/student/review-list'),
    },

    // 学生
    { //阅读报告
      path: '/reportStu',
      name: 'reportStu',
      component: () => import('@/views/student/report'),
    },
    { // 打卡
      path: '/clock',
      name: 'clock',
      component: () => import('@/views/student/clock'),
    },
    { //写读后感
      path: '/writing',
      name: 'writing',
      component: () => import('@/views/student/writing'),
    },
    //挑战
    {
      path: '/challengeStart',
      name: 'challengeStart',
      component: () => import('@/views/challenge/start')
    },
    {
      path: '/challenge',
      name: 'challenge',
      component: () => import('@/views/challenge/index')
    },
    {
      path: '/challengeEnd',
      name: 'challengeEnd',
      component: () => import('@/views/challenge/end')
    },

    //教师
    { //班级统计
      path: '/report',
      name: 'report',
      component: () => import('@/views/teacher/report'),
    },
    {
      path: '/today',
      name: 'today',
      component: () => import('@/views/teacher/today'),
    },
    {
      path: '/reportDetail',
      name: 'reportDetail',
      component: () => import('@/views/teacher/detail'),
    },
    {//教师班级
      path: '/classTeacher',
      name: 'classTeacher',
      component: () => import('@/views/teacher/class-page'),
    },
    {//班级排名
      path: '/classRank',
      name: 'classRank',
      component: () => import('@/views/teacher/rank'),
    },
    {//详细统计
      path: '/statistic',
      name: 'statistic',
      component: () => import('@/views/export/index'),
    },
    {//导出数据
      path: '/export',
      name: 'export',
      component: () => import('@/views/export/export'),
    },
    {//导出数据
      path: '/testState',
      name: 'testState',
      component: () => import('@/views/teacher/test-state'),
    },
    // 购买书券
    { //购买书券
      path: '/buybook',
      name: 'buybook',
      component: () => import('@/views/buybook/buybook'),
    },
    { //购买帮助
      path: '/buyhelp',
      name: 'buyhelp',
      component: () => import('@/views/buybook/buyhelp'),
    },
    { //如何购买
      path: '/howbuy',
      name: 'howbuy',
      component: () => import('@/views/buybook/howbuy'),
    },
    { //消费记录
      path: '/cardrecord',
      name: 'cardrecord',
      component: () => import('@/views/buybook/cardrecord'),
    },
  ],
  scrollBehavior(to, from, saveTop){
      if (saveTop) {
          return saveTop;
      } else {
          return {x: 0, y: 0}
      }
  }
})
